//60秒之后获取验证码
var wait=60;
var retrievePw = new Vue({
    el:'#retrievePw',
    data:{
        emil: '',
        password:'',
        code:''
    },
    methods:{
        send:function(){
            $.ajax({
                url:'getCodeForPasswor',
                type:'POST',
                cache:false,
                dataType:'json',
                data:{
                    emil:this.emil
                },
                success:function(data){
                    if (data.info === "验证码发送成功，有效时间为两分钟！"){
                        window.time();
                    }
                    alert(data.info);
                },
                error:function(){
                    alert("请刷新网络");
                }
            });

        },
        modification:function(){
            $.ajax({
                url:'resetPassword',
                type:'POST',
                cache:false,
                dataType:'json',
                data:{
                    emil:this.emil,
                    password:this.password,
                    code:this.code,
                },
                success:function(data){
                    alert(data.info);
                },
                error:function(){
                    alert("请刷新网络");
                    alert("1111111111111");
                }
            })
        }
    }
});

function time(){
    if (wait == 0) {
        document.getElementById("btn_getcode").removeAttribute("disabled");
        document.getElementById("btn_getcode").value = "重新发送";
        wait = 60;
    } else {
        document.getElementById("btn_getcode").setAttribute("disabled", true);
        document.getElementById("btn_getcode").value = wait+"秒后重新发送";
        wait--;
        setTimeout(function() {
                time()
            },
            1000) ;
    }
};